<?php

namespace app\api\controller;

use app\home\model\LimitAmountConfig;
use Exception;
use think\Cache as ThinkCache;
use think\Controller;

class DingDing extends Controller
{
    
    public function massage(){

        return;
        $get = request()->get();

        $res = ThinkCache::get('diingdin-client'.$get['titlie']);
        if($res){
            echo '中缓存-不发'.$get['titlie'].PHP_EOL;
            exit;
        }
        ThinkCache::set('diingdin-client'.$get['titlie'],'true',30);
        
        $message="【金蟾捕鱼--后台反馈--".$get['titlie']."】++++++++"
        .$get['text'];
        $webhook = "https://oapi.dingtalk.com/robot/send?access_token=8d7017ba2f8e4cf2e05ca330747ac09a26bdce325dad8b387323db116838f098";
        $data = array ('msgtype' => 'text','text' => array ('content' => $message));
        $data_string = json_encode($data);
        $result = $this->request_by_curl($webhook, $data_string); 
        echo $result.PHP_EOL;

    }

    function request_by_curl($remote_server, $post_string) {  
        $ch = curl_init();  
        curl_setopt($ch, CURLOPT_URL, $remote_server);
        curl_setopt($ch, CURLOPT_POST, 1); 
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); 
        curl_setopt($ch, CURLOPT_HTTPHEADER, array ('Content-Type: application/json;charset=utf-8'));
        curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string);  
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  
        // 线下环境不用开启curl证书验证, 未调通情况可尝试添加该代码
        curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0); 
        curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
        $data = curl_exec($ch);
        curl_close($ch);      
        return $data;  
    }  


}


